package jnpf.service.impl;

import jnpf.entity.Whut_paramsEntity;
import jnpf.mapper.Whut_paramsMapper;
import jnpf.service.Whut_paramsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.util.RandomUtil;


import jnpf.model.whut_params.Whut_paramsPagination;
import java.util.stream.Collectors;





import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.text.SimpleDateFormat;
import jnpf.util.*;
import java.util.*;

/**
 *
 * whut_params
 * 版本： V3.2.0
 * 版权： 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * 作者： JNPF开发平台组
 * 日期： 2024-10-05
 */
@Service

public class Whut_paramsServiceImpl extends ServiceImpl<Whut_paramsMapper, Whut_paramsEntity> implements Whut_paramsService {

    @Autowired
    private UserProvider userProvider;






    @Override
    public List<Whut_paramsEntity> getList(Whut_paramsPagination whut_paramsPagination){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
        int total=0;
                    QueryWrapper<Whut_paramsEntity> whut_paramsQueryWrapper=new QueryWrapper<>();
            int whut_paramsNum =0;
			if(StringUtil.isNotEmpty(whut_paramsPagination.getParams())){
            whut_paramsNum++;
            whut_paramsQueryWrapper.lambda().like(Whut_paramsEntity::getParams,whut_paramsPagination.getParams());
                    }

        if(AllIdList.size()>0){
            whut_paramsQueryWrapper.lambda().in(Whut_paramsEntity::getId, AllIdList);
        }
        //排序
        if(StringUtil.isEmpty(whut_paramsPagination.getSidx())){
        whut_paramsQueryWrapper.lambda().orderByDesc(Whut_paramsEntity::getId);
        }else{
        whut_paramsQueryWrapper="asc".equals(whut_paramsPagination.getSort().toLowerCase())?whut_paramsQueryWrapper.orderByAsc(whut_paramsPagination.getSidx()):whut_paramsQueryWrapper.orderByDesc(whut_paramsPagination.getSidx());
        }
        if((total>0 && AllIdList.size()>0) || total==0){
        Page<Whut_paramsEntity> page=new Page<>(whut_paramsPagination.getCurrentPage(), whut_paramsPagination.getPageSize());
        IPage<Whut_paramsEntity> userIPage=this.page(page, whut_paramsQueryWrapper);
        return whut_paramsPagination.setData(userIPage.getRecords(),userIPage.getTotal());
        }else{
            List<Whut_paramsEntity> list = new ArrayList();
            return whut_paramsPagination.setData(list, list.size());
        }
    }
    @Override
    public List<Whut_paramsEntity> getTypeList(Whut_paramsPagination whut_paramsPagination,String dataType){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
		int total=0;
                    QueryWrapper<Whut_paramsEntity> whut_paramsQueryWrapper=new QueryWrapper<>();
            int whut_paramsNum =0;
			if(StringUtil.isNotEmpty(whut_paramsPagination.getParams())){
            whut_paramsNum++;
            whut_paramsQueryWrapper.lambda().like(Whut_paramsEntity::getParams,whut_paramsPagination.getParams());
                    }

		if(AllIdList.size()>0){
        whut_paramsQueryWrapper.lambda().in(Whut_paramsEntity::getId, AllIdList);
				}
        //排序
        if(StringUtil.isEmpty(whut_paramsPagination.getSidx())){
        whut_paramsQueryWrapper.lambda().orderByDesc(Whut_paramsEntity::getId);
        }else{
        whut_paramsQueryWrapper="asc".equals(whut_paramsPagination.getSort().toLowerCase())?whut_paramsQueryWrapper.orderByAsc(whut_paramsPagination.getSidx()):whut_paramsQueryWrapper.orderByDesc(whut_paramsPagination.getSidx());
        }
        if("0".equals(dataType)){
            if((total>0 && AllIdList.size()>0) || total==0){
                Page<Whut_paramsEntity> page=new Page<>(whut_paramsPagination.getCurrentPage(), whut_paramsPagination.getPageSize());
                IPage<Whut_paramsEntity> userIPage=this.page(page, whut_paramsQueryWrapper);
                return whut_paramsPagination.setData(userIPage.getRecords(),userIPage.getTotal());
            }else{
                List<Whut_paramsEntity> list = new ArrayList();
                return whut_paramsPagination.setData(list, list.size());
            }
        }else{
            return this.list(whut_paramsQueryWrapper);
        }
    }

    @Override
    public Whut_paramsEntity getInfo(String id){
        QueryWrapper<Whut_paramsEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(Whut_paramsEntity::getId,id);
        return this.getOne(queryWrapper);
    }

    @Override
    public void create(Whut_paramsEntity entity){
        this.save(entity);
    }

    @Override
    public boolean update(String id, Whut_paramsEntity entity){
        entity.setId(id);
        return this.updateById(entity);
    }
    @Override
    public void delete(Whut_paramsEntity entity){
        if(entity!=null){
            this.removeById(entity.getId());
        }
    }
    //子表方法

    //列表子表数据方法

}